Skip to content

feat(markdown): render frontmatter in file previews - #8202

Closed
tarik02 wants to merge 8 commits into
pingdotgg:mainfrom
tarik02:fix/render-markdown-frontmatter
Closed

feat(markdown): render frontmatter in file previews#8202
tarik02 wants to merge 8 commits into
pingdotgg:mainfrom
tarik02:fix/render-markdown-frontmatter

Conversation

@tarik02

@tarik02 tarik02 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

What Changed

Markdown file previews now render leading YAML frontmatter as a metadata table on web, desktop, and mobile.

Scalar arrays render as pills. Nested values render as YAML. Invalid, unclosed, and non-mapping frontmatter remains unchanged.

Why

File previews previously displayed frontmatter as raw Markdown delimiters and YAML. This matches GitHub's metadata-table presentation while keeping parsing shared and platform rendering local.

UI Changes

Before: browser-screenshot-linux-t3-tarik02-me-mt8pqmtj

After: browser-screenshot-localhost-mt8ppbw6

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for the UI changes
  • No animation or interaction changes require a video

Implemented with GPT-5.6 Sol using Codex in T3 Code.


Note

Medium Risk
Strips frontmatter from the rendered stream and shifts task-list save offsets; a parsing or offset bug could mis-edit markdown files that include frontmatter.

Overview
Rendered markdown file previews now peel off leading --- YAML frontmatter and show it as a metadata table above the body on web/desktop and mobile, instead of rendering the raw delimiter block as markdown.

A shared parseMarkdownFrontmatter export splits the file into entries, body, and bodyOffset (for mapping edits back into the full source). Scalars render as text, homogeneous scalar arrays as pills/badges, and nested structures as monospace YAML. Invalid, unclosed, or non-mapping frontmatter is left in the body unchanged.

Web RenderedMarkdownSurface passes only frontmatter.body to ChatMarkdown and adds frontmatter.bodyOffset when applying task-list checkbox toggles via setMarkdownTaskChecked. Mobile FileMarkdownPreview does the same split for native/selectable markdown renderers. New platform MarkdownFrontmatterTable components handle layout; web adds a .markdown-table CSS hook sharing compact table styling with chat markdown. User docs describe detection and fallback behavior.

Reviewed by Cursor Bugbot for commit ae9eea8. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Render YAML frontmatter as a metadata table in file previews

  • Adds shared parseMarkdownFrontmatter in markdownFrontmatter.ts (exported via ./markdown-frontmatter) that splits a markdown string into frontmatter entries, a body segment, and a bodyOffset for source mapping
  • Mobile (FileMarkdownPreview.tsx) and web (FilePreviewPanel.tsx) now render a new MarkdownFrontmatterTable above the markdown body and pass only frontmatter.body to the markdown renderer
  • Frontmatter values render as text, pill/badge lists, or monospace YAML depending on their inferred type
  • Web adjusts onTaskListChange marker offsets by frontmatter.bodyOffset so checkbox mutations map back to the original file contents
  • Extends index.css with a .markdown-table class sharing compact table styles with .chat-markdown without the chat-specific overflow rules
  • Behavioral Change: rendered markdown no longer includes the raw frontmatter block; files without valid --- delimited frontmatter render unchanged

Macroscope summarized ae9eea8.

Summary by CodeRabbit

  • New Features

    • Markdown file previews now detect and display YAML frontmatter metadata in formatted tables across web and mobile.
    • Metadata values support text, lists, and structured YAML formatting.
    • Markdown content renders separately from its frontmatter, with task-list editing preserved.
    • Invalid or unsupported frontmatter safely falls back to standard Markdown rendering.
  • Documentation

    • Added documentation covering frontmatter detection, display, formatting, and fallback behavior.

@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f5546fdc-518f-42b3-8755-77d24d974b38

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e7529d5f-845a-407d-b54a-bf29dde36765

📥 Commits

Reviewing files that changed from the base of the PR and between e67074f and 999709f.

📒 Files selected for processing (8)
  • apps/mobile/src/features/files/FileMarkdownPreview.tsx
  • apps/mobile/src/features/files/MarkdownFrontmatterTable.tsx
  • apps/web/src/components/files/FilePreviewPanel.tsx
  • apps/web/src/components/files/MarkdownFrontmatterTable.tsx
  • apps/web/src/index.css
  • docs/user/file-previews.md
  • packages/client-runtime/package.json
  • packages/client-runtime/src/markdownFrontmatter.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Adds shared YAML frontmatter parsing and display types. Web and mobile Markdown previews now show frontmatter in tables and render only the Markdown body. Task-list edits account for the removed frontmatter offset. Documentation covers formatting and fallback behavior.

Changes

Markdown frontmatter previews

Layer / File(s) Summary
Frontmatter parsing and display contract
packages/client-runtime/src/markdownFrontmatter.ts, packages/client-runtime/package.json
Adds YAML frontmatter parsing, display-value conversion, parsed body offsets, entry types, and a package export.
Frontmatter table rendering
apps/web/src/components/files/MarkdownFrontmatterTable.tsx, apps/mobile/src/features/files/MarkdownFrontmatterTable.tsx, apps/web/src/index.css
Adds scrollable tables for text, list, and YAML values. Mobile rendering measures key-column widths. Shared table styling supports the new tables.
Preview integration and documentation
apps/web/src/components/files/FilePreviewPanel.tsx, apps/mobile/src/features/files/FileMarkdownPreview.tsx, docs/user/file-previews.md
Integrates frontmatter parsing and tables into web and mobile previews. Renders only the parsed body and adjusts web task-list offsets. Documents formatting and fallback behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: 🟡 Moderate · up to 99970

Frontmatter rendering changes the coordinates used when editing task-list checkboxes in web previews. If a file changes concurrently, an edit could toggle the wrong checkbox, and a failed save may leave the preview showing changes that were not persisted. This should be fixed or explicitly accepted before merging.

Sequence Diagram(s)

sequenceDiagram
  participant FilePreview
  participant Parser as parseMarkdownFrontmatter
  participant Table as MarkdownFrontmatterTable
  participant Renderer as ChatMarkdown
  FilePreview->>Parser: Parse Markdown source
  Parser-->>FilePreview: Return entries, body, and bodyOffset
  FilePreview->>Table: Render frontmatter entries
  FilePreview->>Renderer: Render parsed body
  FilePreview->>FilePreview: Apply bodyOffset to task-list edits
Loading

Suggested reviewers: juliusmarminge

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 5 files. (3 skipped: 3 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: rendering Markdown frontmatter in file previews.
Description check ✅ Passed The description includes the required What Changed, Why, UI Changes, and Checklist sections. It explains the implementation, fallback behavior, and includes before-and-after screenshots.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 5 files. (3 skipped: 3 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Aug 25, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 39107ac224

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +734 to +735
{frontmatter.entries.length > 0 ? (
<MarkdownFrontmatterTable entries={frontmatter.entries} />

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Document the new frontmatter preview behavior

This introduces user-visible frontmatter rendering across the web, desktop, and mobile file previews, but the commit adds no corresponding docs/user/ documentation. Add shipped-product documentation explaining when leading YAML frontmatter is rendered and which values remain unchanged.

AGENTS.md reference: AGENTS.md:L75-L75

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed!

Comment thread apps/mobile/src/features/files/MarkdownFrontmatterTable.tsx Outdated
@macroscopeapp

macroscopeapp Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This PR adds a new shared frontmatter parser and metadata-table rendering across web and mobile previews, including changes to rendered Markdown and task-list offset handling. The cross-platform user-facing behavior and multiple new components warrant human review.

You can add or adjust custom eligibility rules. Learn more.

@macroscopeapp macroscopeapp Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the new web frontmatter table and its call site in FilePreviewPanel. Two consistency findings on apps/web/src/components/files/MarkdownFrontmatterTable.tsx: the table reconstructs table/overflow treatment that the rendered-markdown surface already owns, and the list pills reconstruct Badge. The task-offset rebasing in RenderedMarkdownSurface and the token usage (border-border, text-foreground/80 are bridged to the --contrast-* roles in index.css) look correct.

Posted via Macroscope — UI Consistency

Comment thread apps/web/src/components/files/MarkdownFrontmatterTable.tsx Outdated
Comment thread apps/web/src/components/files/MarkdownFrontmatterTable.tsx Outdated
Comment thread apps/mobile/src/features/files/MarkdownFrontmatterTable.tsx

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 09e8576. Configure here.

Comment thread apps/web/src/components/files/MarkdownFrontmatterTable.tsx Outdated
Comment thread apps/mobile/src/features/files/MarkdownFrontmatterTable.tsx Outdated

@macroscopeapp macroscopeapp Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two ownership/behavior issues in the new frontmatter table styling. Both stem from reusing the .chat-markdown table rules for .markdown-table without the surrounding contract those rules assume.

Posted via Macroscope — UI Consistency

<tr key={entry.key}>
<th
scope="row"
className="w-px whitespace-nowrap bg-muted/30 !text-right align-middle font-semibold text-foreground"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ! on !text-right is only needed because this PR adds .markdown-table th to the unlayered text-align: left rule in index.css, and unlayered global CSS outranks Tailwind's layered utilities — the owner ends up overriding its own global rule with !important, which is fragile for any later cell that wants a different alignment.

Consider scoping the global rule to the cells that actually want left alignment (.chat-markdown th, .chat-markdown td, .markdown-table td, keeping the shared padding for .markdown-table th) and leaving alignment at the owner as a plain text-right.

Posted via Macroscope — UI Consistency

Comment thread apps/web/src/index.css
@tarik02

tarik02 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@t3dotgg

t3dotgg commented Aug 28, 2026

Copy link
Copy Markdown
Member

Note

🤖 GPT-5.6 Sol responding on behalf of Theo

We're closing this PR as we clean up the T3 Code backlog. Thank you for taking the time to put this together.

We are not adding frontmatter rendering to file previews in this pass. The preview remains usable, and this extra presentation rule is not a priority for the active queue.

If you believe we closed this in error, please reopen the PR and leave a comment explaining what we missed.

@t3dotgg t3dotgg closed this Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants